package com.oliver.picturebackendcommon.config;

import cn.hutool.core.thread.NamedThreadFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName ThreadPoolConfig
 * @Description TODO
 * @Author snow
 * @Date 2025/1/1 15:39
 **/

@Configuration
public class ThreadPoolConfig {

    @Bean("customExecutor")
    public ThreadPoolExecutor threadPoolExecutor(){
        return new ThreadPoolExecutor(
                5,
                10,
                10,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(),
                new NamedThreadFactory("oliver - ",false),
                new ThreadPoolExecutor.DiscardPolicy()
        );
    }

}
